<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>提现记录</title>
	<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"/>
	<meta content="yes" name="apple-mobile-web-app-capable"/>
	<meta content="black" name="apple-mobile-web-app-status-bar-style"/>
	<meta content="telephone=no" name="format-detection"/>
	<link type="text/css" rel="stylesheet" href="../themes/css/base.css">
	<link type="text/css" rel="stylesheet" href="../themes/css/home.css">
	<link type="text/css" rel="stylesheet" href="../themes/css/icon.css">
</head>
<body>

	<header class="aui-navBar aui-navBar-fixed b-line">
		<a href="javascript:history.go(-1);" class="aui-navBar-item">
			<i class="icon icon-return"></i>
		</a>
		<div class="aui-center">
			<span class="aui-center-title">提现记录(<span id="countNum">0</span>)</span>
		</div>
		<a href="javascript:;" class="aui-navBar-item">
			<i class="icon icon-sys"></i>
		</a>
	</header>

		<div class="aui-carry-list">
			<div class="aui-carry-border"></div>
			<div class="aui-carry-table">
				<table>
					<thead>
						<tr>
							<th>申请人</th>
							<th>金额</th>
							<th>状态</th>
							<th>时间</th>
						</tr>
					</thead>
					<tbody id="carryLs">
					</tbody>
				</table>
				<span id="carryLs2"></span>
				<span id="indexNum"  style="display:none;">1</span>
				<span id="flagls"  style="display:none;">Y</span>
			</div>
		</div>

</body>
<script type="text/javascript" src="../themes/js/jquery.min.js"></script>
<script type="text/javascript" src="../themes/js/slider.js"></script>
<script type="text/javascript" src="../themes/js/layer.js"></script>
<script type="text/javascript">
	function b() {
		t = parseInt(x.css('top'));
		y.css('top', '20px');
		x.animate({
			top: t - 20 + 'px'
		}, 'slow');
		if (Math.abs(t) == h - 20) {
			y.animate({
				top: '0px'
			}, 'slow');
			z = x;
			x = y;
			y = z;
		}
		setTimeout(b, 3000);
	}
	$(document).ready(function() {
        init();
		$('.swap').html($('.news_li').html());
		x = $('.news_li');
		y = $('.swap');
		h = $('.news_li li').length * 20;
		setTimeout(b, 3000);

// 设置布尔值用于判断是否该DIV到达过可视区域
        // 监听滚轮事件
        $(window).scroll(function() {
            var   viewH =$(this).height();//可见高度
            var   contentH =$("#carryLs").height()-viewH;//内容高度
            var   scrollTop =$(this).scrollTop();//滚动高度
            if ("Y" == $("#flagls").text()) {
                // 判断
                // $(window).scrollTop()为返回滚动条的垂直位置
                // $(window).height()代表了当前可见区域的大小,即你看到的浏览器显示范围
                if (scrollTop>contentH ) {
                    // 如果到达了可视区域，则设置其布尔值为false，防止一直调用下面函数，即只做一次ajax请求
                    $("#flagls").text("N");
                    // 你的ajax请求函数
                    loaddata();
                }
            }
        })

        function loaddata() {
            var index=$("#indexNum").text();
            $.ajax({
                async:false,
                url: "../withdraw/getCashLs2",
                dataType: "json",
                data:{"indexNum":index},
                success:function (data) {
                    $.each(data.withdrawals, function(index, elem) {
                        var state=elem[2]>0?"已到账":"提现中";
                        var head="<tr><td>"+elem[0]+"</td> <td>"+elem[1]+"</td> <td>"+state+"</td> <td>"+elem[3]+"</td></tr>"
                        $('#carryLs').append(head);
                        $("#indexNum").text(data.indexNum);
                        $("#flagls").text("Y");
                        console.log("回调:"+data.indexNum);
                    });
                }
            });

        }
	});

    function init() {
        $.ajax({
            url: "../withdraw/getCashLs",
            success:function (data) {
                $('#countNum').text(data.countNum);
               var count=data.withdrawals.length;
                if(0==count){
                    $('#carryLs2').append('<div style=";text-align:center;font-size:14px;color:#bbb;">您还没有提现记录哦~</div>');
                }
                $.each(data.withdrawals, function(index, elem) {
                    var state=elem[2]>0?"已到账":"提现中";
                    var head="<tr><td>"+elem[0]+"</td> <td>"+elem[1]+"</td> <td>"+state+"</td> <td>"+elem[3]+"</td></tr>"
                    $('#carryLs').append(head);
                });
            }
        });
    }

</script>
</html>
